package com.doupi.partner.util.constant;

import org.apache.commons.lang3.StringUtils;

/**
 * 环境模式
 * 
 * @author Alvin Wang
 * @version 1.0 @ 2017-03-30
 */
public enum ProfileEnum {
	DEBUG("DEBUG", 1), TEST("TEST", 2), ONLINE("ONLINE", 3), DEFAULT("DEFAULT", 4);

	private String code;
	private int orderIndex;

	ProfileEnum(String code, int orderIndex) {
		this.code = code;
		this.orderIndex = orderIndex;
	}

	public String getCode() {
		return code;
	}

	public int getOrderIndex() {
		return orderIndex;
	}

	/**
	 * 根据 code获取profile
	 * 
	 * @param code
	 *            code
	 * @return {@link ProfileEnum}
	 */
	public static ProfileEnum getProfileByCode(String code) {
		for (ProfileEnum profileEnum : values()) {
			if (StringUtils.equalsIgnoreCase(profileEnum.getCode(), code)) {
				return profileEnum;
			}
		}
		return null;
	}
}
